/*java jdk 1.7+
# -*- coding: utf-8 -
'''
Created on 2022年07月06日
@author: zxyong 13738196011
'''*/

package com.plugins.usereflect;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedHashMap;

import org.json.JSONObject;

import com.zxy.common.Com_Fun;
import com.zxy.common.Com_Para;
import com.zxy.db_Self.Db_Common_Self;

//导出数据结构信息
public class A01_TBINFO_IN implements com.zxy.common.ParamName_InterFace
{
	public StringBuilder	strResult		= new StringBuilder();
	public String			user_main_id	= null;
	public String			session_id		= null;
	public String			param_name		= null;
	public String			param_value1	= null;
	public String			param_value2	= null;
	public String			param_value3	= null;
	public String			param_value4	= null;
	public String			param_value5	= null;
	public String			param_value6	= null;
	public String			param_value7	= null;
	public String			param_value8	= null;
	public String			param_value9	= null;
	public String			param_value10	= null;
	
	public void init_start()
	{
		JSONObject jsoResult = new JSONObject(new LinkedHashMap());
		JSONObject jso = new JSONObject(new LinkedHashMap());
		StringBuilder strSql = new StringBuilder();
		ResultSet rs = null;
		try
		{
			if(!java.util.Objects.equals(Com_Fun.NoNull(this.param_value1),"")){
				Db_Common_Self dbc_ic = new Db_Common_Self();
				strSql.append("SELECT a.MAIN_ID,a.TABLE_CN_NAME,a.TABLE_EN_NAME,b.DB_CN_NAME FROM t_single_table a "
						+ " join t_db_config b on a.DB_ID = b.MAIN_ID where TABLE_TYPE = '0' "
						+" and a.main_id in ('','"
						+ this.param_value1.replace(",","','") + "')"
						+" order by b.S_SORT,a.S_SORT asc");
				rs = dbc_ic.Common_Sql(strSql);
				jso.put("t_single_table",Com_Fun.ResultSetToJSON(rs));
				
				strSql.delete(0,strSql.length());
				strSql.append("SELECT a.MAIN_ID,a.TABLE_ID,a.COLUMN_CN_NAME,a.COLUMN_EN_NAME,COLUMN_TYPE,COLUMN_LENGTH "
						+" FROM t_table_column a where a.TABLE_ID in ('','"
						+ this.param_value1.replace(",","','") + "') order by a.S_SORT asc");
				rs = dbc_ic.Common_Sql(strSql);
				jso.put("t_table_column",Com_Fun.ResultSetToJSON(rs));
								
				strSql.delete(0,strSql.length());
				strSql.append("SELECT a.MAIN_ID,b.TABLE_ID,concat(b.COLUMN_EN_NAME,'(',b.COLUMN_CN_NAME,')') as 'MAIN_TB_NAME',"
						+"concat(d.TABLE_EN_NAME,'(',d.TABLE_CN_NAME,')','=>',c.COLUMN_EN_NAME,'(',c.COLUMN_CN_NAME,')') "
						+"as 'SUB_TB_NAME' FROM t_main_sub_link a "
						+"join t_table_column b on a.MAIN_TB_NAME = b.MAIN_ID "
						+"join t_table_column c on a.SUB_TB_NAME = c.MAIN_ID "
						+"join t_single_table d on c.TABLE_ID = d.MAIN_ID where b.TABLE_ID in ('','"
						+ this.param_value1.replace(",","','") + "') order by a.S_SORT asc");
				rs = dbc_ic.Common_Sql(strSql);
				jso.put("t_main_sub_link",Com_Fun.ResultSetToJSON(rs));
				
				jsoResult.put(this.param_name,jso);
				this.strResult.append(jsoResult.toString());
			}
			else{
				this.strResult.append(Com_Fun.get_ope_result(param_name,"0","至少选择一条数据记录"));
			}
		}
		catch(Exception e)
		{
			Com_Fun.debug_in(e,this.toString(),strSql.toString());
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
	}

	public StringBuilder getStrResult()
	{
		return strResult;
	}

	public void setStrResult(StringBuilder strResult)
	{
		this.strResult = strResult;
	}

	public String getUser_main_id()
	{
		return user_main_id;
	}

	public void setUser_main_id(String user_main_id)
	{
		this.user_main_id = user_main_id;
	}

	public String getSession_id()
	{
		return session_id;
	}

	public void setSession_id(String session_id)
	{
		this.session_id = session_id;
	}

	public String getParam_name()
	{
		return param_name;
	}

	public void setParam_name(String param_name)
	{
		this.param_name = param_name;
	}

	public String getParam_value1()
	{
		return param_value1;
	}

	public void setParam_value1(String param_value1)
	{
		this.param_value1 = param_value1;
	}

	public String getParam_value2()
	{
		return param_value2;
	}

	public void setParam_value2(String param_value2)
	{
		this.param_value2 = param_value2;
	}

	public String getParam_value3()
	{
		return param_value3;
	}

	public void setParam_value3(String param_value3)
	{
		this.param_value3 = param_value3;
	}

	public String getParam_value4()
	{
		return param_value4;
	}

	public void setParam_value4(String param_value4)
	{
		this.param_value4 = param_value4;
	}

	public String getParam_value5()
	{
		return param_value5;
	}

	public void setParam_value5(String param_value5)
	{
		this.param_value5 = param_value5;
	}

	public String getParam_value6()
	{
		return param_value6;
	}

	public void setParam_value6(String param_value6)
	{
		this.param_value6 = param_value6;
	}

	public String getParam_value7()
	{
		return param_value7;
	}

	public void setParam_value7(String param_value7)
	{
		this.param_value7 = param_value7;
	}

	public String getParam_value8()
	{
		return param_value8;
	}

	public void setParam_value8(String param_value8)
	{
		this.param_value8 = param_value8;
	}

	public String getParam_value9()
	{
		return param_value9;
	}

	public void setParam_value9(String param_value9)
	{
		this.param_value9 = param_value9;
	}

	public String getParam_value10()
	{
		return param_value10;
	}

	public void setParam_value10(String param_value10)
	{
		this.param_value10 = param_value10;
	}
}
